import {Component, ViewChild} from "@angular/core";
import {Platform, AlertController, MenuController, Nav} from "ionic-angular";
import {StatusBar, Splashscreen} from "ionic-native";
import {LoginPage} from "../pages/Login/LoginPage";
import {RegisterPage} from "../pages/Register/RegisterPage";
import {EvaluationPage} from "../pages/Evaluation/EvaluationPage";
import {NewPostPage} from "../pages/NewPost/NewPostPage";

@Component({
    templateUrl: 'app.html'
})
export class MyApp {
    // variables to control UI
    rootPage: Component = EvaluationPage;
    pages = [
        {title: '登录', component: LoginPage},
        {title: '注册', component: RegisterPage},
    ];

    @ViewChild(Nav)
    nav: Nav;
    // static variables
    static instance: MyApp;

    constructor(public platform: Platform,
                public alertController: AlertController,
                public menu: MenuController) {
        MyApp.instance = this;
        platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            StatusBar.styleDefault();
            Splashscreen.hide();
        });
    }

    openPage(pageInfo) {
        this.menu.close();
        this.nav.setRoot(pageInfo.component);
    }
}
